home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15938 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  845 b 

  1. Path: news.logicon.com!newsmaster@klee
  2. From: kkolda@logicon.com (Kenneth D. Kolda)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: reading textfiles...
  5. Date: 8 Apr 1996 20:34:46 GMT
  6. Organization: Logicon Operating Systems
  7. Message-ID: <4kbt96$6jh@piper.logicon.com>
  8. References: <4k7p6p$i7s@netnews.upenn.edu>
  9. NNTP-Posting-Host: 137.51.122.161
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.99.2
  12.  
  13. In article <4k7p6p$i7s@netnews.upenn.edu>, son@blue.seas.upenn.edu 
  14. says...
  15. >
  16. >How do I read in a text file one line at a time?
  17. >
  18. >ifstream inFile(file, ios::in);
  19. >
  20. >inFile.get() reads in one character at a time,but how do i read a whole 
  21. line?
  22. >
  23.  
  24. Use istream::getline(char*, int) -- it reads to the next '\n', NULL 
  25. terminates your string (the '\n' is NOT included in the string) and 
  26. discards the '\n' (so you don't get it on subsequent reads).
  27.  
  28. Ken Kolda
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.